package com.briup.srms.sms.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.srms.sms.bean.EmployeeEvent;
import com.briup.srms.sms.bean.extend.EmployeeEventExtend;
import com.briup.srms.sms.dao.EmployeeEventMapper;
import com.briup.srms.sms.dao.extend.EmployeeEventExtendMapper;
import com.briup.srms.sms.service.IEmployeeEventService;
import com.jacky.base.utils.CustomerException;
import com.jacky.base.utils.PageVM;
@Service
public class EmployeeEventServiceImpl implements IEmployeeEventService {
	
	@Autowired
	private EmployeeEventMapper employeeEventMapper;
	@Autowired
	private EmployeeEventExtendMapper employeeEventExtendMapper;

	
	@Override
	public PageVM<EmployeeEventExtend> pageQuery(int page, int pageSize, Long employeeId,String event,Long clazzId) {
		List<EmployeeEventExtend> list = employeeEventExtendMapper.query(page, pageSize, employeeId,event,clazzId);
		long total = employeeEventExtendMapper.count( employeeId,event,clazzId);
		return new PageVM<>(page, pageSize, total, list);
	}
	
	@Override
	public void deleteById(long id) throws CustomerException{
		employeeEventMapper.deleteByPrimaryKey(id);
	}
	
	@Override
	public void saveOrUpdate(EmployeeEvent employeeEvent,long roleId) throws CustomerException {
		if(employeeEvent.getId() == null) {
			employeeEvent.setInsertTime(new Date().getTime());
			employeeEventMapper.insert(employeeEvent);
		} else {
			employeeEventMapper.updateByPrimaryKey(employeeEvent);
		}
	}
}
